home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 165 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  4.4 KB

  1. Path: solon.com!not-for-mail
  2. From: tanmoy@qcd.Lanl.GOV (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c.moderated,comp.std.c
  4. Subject: Re: Is this legal prototype syntax?
  5. Date: 23 Jan 1996 06:34:32 -0600
  6. Organization: Los Alamos National Laboratory
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4e2kko$l25@solutions.solon.com>
  10. References: <4dp6l2$ntq@solutions.solon.com> <4dpv3g$qq3@solutions.solon.com>
  11.     <4duuat$563@solutions.solon.com> <4e1mna$hnj@solutions.solon.com>
  12. NNTP-Posting-Host: solutions.solon.com
  13.  
  14. --text follows this line--
  15.  
  16. Please note crosspost.
  17.  
  18. In article <4e1mna$hnj@solutions.solon.com> The Amorphous Mass
  19. <robinson@blue.weeg.uiowa.edu> writes: 
  20. <snip>
  21.    >     Yes.  *b and b[] are identical in the context of function parameter lists.
  22.    > 
  23.    > Actually, the correct answer is _currently_ they are
  24.    > identical. However, there is an intent in the standard (i.e. the
  25.    > standard encourages following this rule) that if two objects are
  26.    > declared arrays instead of pointers (even though they will be adjusted
  27.    > to pointers), they will be distinct objects. Thus, it is better not to
  28.    > say void FTNSUB(int *a, int b[], int c[]) unless b and c will always
  29.    > be distinct. Note that a need never be distinct: an object declared
  30.    > pointer can point anywhere.
  31.  
  32.      Hmmm.  Could you elaborate?  Does that mean that if I have
  33.  
  34. My statement is based on the single sentence
  35.  
  36. 6.9.6 The use of two parameters declared with an array type (prior to
  37. adjustment to pointer type) in separate lvalues to designate the same
  38. object is an obsolescent feature.
  39.  
  40. For comp.std.c { I must admit I do not follow how two parameters can
  41. be declared with an array type in non-separate lvalues, the cross-post
  42. to comp.std.c may result in further illumination. More likely, the
  43. statement means that two _distinct_ parameters, each declared with an
  44. array type, may not be used to form separate lvalues, if the said
  45. lvalues refer to the same object: i.e. if b and c are two parameters
  46. *(b+3) must not be the same object *(c+2) either if both are used. Of
  47. course this interpretation would also demand that for any pointers a,
  48. if *(a+(b-b)) is used, *(a+(c-c)) must not be. This is peculiar to say
  49. the least.
  50.  
  51. `may' or `may not' in the above para refer to requirements to prevent
  52. obsolescence.
  53. }
  54.  
  55.      int a[100];
  56.      f(a);
  57.      /* ... */
  58.      void f(int b[]) { /* ... */ } /* assume f has been prototyped */
  59.  
  60.      that I can't treat b as a pointer to a?  Or, if I have
  61.  
  62. I do not think the statement applies to this. There are no two
  63. parameters declared with an array type. In any case, what the intent
  64. may be is that the compiler may some day legally make the assumption
  65. that two array parameters are distinct, and hence optimize
  66. accordingly. From my reading of that statement, a parameter
  67. overlapping a global continues to remain a possibility. Whether this
  68. was intended, I cannot say. I can see, vaguely, reasons for allowing
  69. overlaps with global: echoes of noalias resound otherwise.
  70.  
  71.      int *a = malloc(100 * sizeof(int));
  72.      f(a);
  73.      /* ... */
  74.      void f(int b[]) { /* ... */ }
  75.  
  76.      that b is treated something like a const pointer to int?  Will this 
  77.  
  78. No. It will continue to be a pointer to int.
  79.  
  80.    affect people who use int main(int argc, char *argv[]) instead of int 
  81.    main(int argc, char **argv[])?  Will the two statements remain equivalent 
  82.  
  83. I hope nobody uses the char **argv[] form :-) Whether the char *argv[]
  84. and char **argv will continue to remain equivalent I cannot say
  85. reading the standard alone, but note that technically the standard
  86. only says that char *argv[] is legal: the legality of char **argv
  87. depends on the equivalence, not the other way round.
  88.  
  89.    or not?  Or is this just for inter-language purposes, as your FTNSUB 
  90.    example implies?
  91.  
  92. No, it is only to leave room for later standards to make the meaning
  93. clearer. 
  94.  
  95.      Thanks for any enlightenment you can provide.
  96.  
  97. I am waiting for enlightenment myself ...
  98.  
  99. Cheers
  100. Tanmoy
  101. --
  102. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  103. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  104. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  105. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  106. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  107. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  108.